<template>
  <div class="header-sencond">
    <el-row style="margin-bottom: 20px">
      <el-col :span="taskId != -1 ? 18 : 24">
        <div class="status-16">
          <span></span><span>{{ taskStatusEnum[taskStatus] }}</span
          ><span>{{ progress || 0 }}%</span>
        </div>
        <el-progress
          :stroke-width="10"
          :percentage="progress"
          color="#00D1FF"
        ></el-progress>
        <div>
          &nbsp;
          <span
            >{{
              taskId != -1 ? $t("巡检中") + "：" : $t("即将执行")
            }}&nbsp;</span
          >
          <el-tooltip
            v-if="taskId != -1"
            class="item"
            effect="dark"
            :content="taskName"
            placement="left"
          >
            <span>{{ taskName | handleCtx("8") }}</span>
          </el-tooltip>
          <span v-else>{{ taskName }}</span>
          <span v-if="taskId != -1">
            <span>/</span>
            <el-tooltip
              v-if="taskId != -1"
              class="item"
              effect="dark"
              :content="
                demission == '2' ? taskInfo.viewPointName : taskInfo.deviceName
              "
              placement="right"
            >
              <span v-if="taskInfo.viewPointName">{{
                demission == "2"
                  ? taskInfo.viewPointName
                  : taskInfo.deviceName | handleCtx("8")
              }}</span>
            </el-tooltip>
          </span>
        </div>
      </el-col>
      <el-col v-if="taskId != -1" :span="6" class="status-btn-8">
        <div class="cursor-pointer" @click="taskHandle('pause')">
          {{ progreeTitle }}
        </div>
        <div class="cursor-pointer" @click="taskHandle('stop')">
          {{ $t("终止") }}
        </div>
      </el-col>
    </el-row>
    <el-row :gutter="20" class="square">
      <el-col
        :style="{ cursor: taskId == -1 ? 'pointer' : 'default' }"
        :span="4"
      >
        <div @click="handelMission">
          <div style="text-align: center">{{ totalTaskCount || 0 }}</div>
          <div>
            {{
              taskId != -1
                ? demission == "1"
                  ? $t("巡检对象总数")
                  : $t("巡检点总数")
                : $t("今日任务总数")
            }}
          </div>
        </div>
      </el-col>
      <el-col :span="4">
        <div>{{ executedTaskCount || 0 }}/{{ unExecutedTaskCount || 0 }}</div>
        <div>
          {{ taskId != -1 ? $t("已巡待巡") : $t("已执行待执行") }}
        </div>
        <div></div>
      </el-col>
      <el-col :span="4">
        <div>{{ abNormalCount || 0 }}/{{ normalCount || 0 }}</div>
        <div>{{ $t("告警正常") }}</div>
        <div></div>
      </el-col>
      <el-col :span="4">
        <!-- <div>{{ taskInfo.leftTime || 0 }}</div> -->
        <div v-if="isChoosenMode == 0">
          {{ hours }}:{{ minutes }}:{{ seconds }}
        </div>
        <el-tooltip
          v-else
          class="item"
          effect="dark"
          content="当前非任务模式，请先切换至任务模式"
          placement="left"
        >
          <div>- : - : -</div>
        </el-tooltip>
        <div>
          {{ taskId != -1 ? $t("预计剩余时间") : $t("距下次任务还剩") }}
        </div>
        <div></div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
export default {
  props: [
    "taskStatus",
    "progress",
    "taskId",
    "demission",
    "taskName",
    "taskInfo",
    "progreeTitle",
    "totalTaskCount",
    "executedTaskCount",
    "unExecutedTaskCount",
    "abNormalCount",
    "normalCount",
    "isChoosenMode",
    "hours",
    "minutes",
    "seconds",
  ],

  data() {
    return {
      taskStatusEnum: {
        0: this.$t("无"),
        1: this.$t("等待执行"),
        2: this.$t("任务超期"),
        3: this.$t("正在执行"),
        4: this.$t("中途暂停"),
        5: this.$t("执行完成"),
        6: this.$t("中途停止"),
        7: this.$t("识别中"),
        99: this.$t("待机"),
      },
    };
  },
  watch: {
    taskStatus: {
      handler(val) {
        if (val == "4") {
          this.$set(this, "progreeTitle", this.$t("恢复"));
        } else {
          this.$set(this, "progreeTitle", this.$t("暂停"));
        }
      },
      immediate: true,
    },
  },
  created() {},
  mounted() {},
  methods: {
    // 点击今日任务总数  弹框
    handelMission() {
      //   this.dialogVal = true;
      this.$emit("handelMission");
    },
    /**暂停 终止*/
    taskHandle(type) {
      this.$emit("handleTask", type);
    },
  },
};
</script>
<style lang="scss" scoped>
// 巡检状态
.header-sencond {
  height: 184px;
  padding: 12px;
  border-left: 1px solid rgba(241, 243, 249, 0.2);
  border-right: 1px solid rgba(241, 243, 249, 0.2);
  .el-row {
    height: 50%;
  }
  .status-16 {
    position: relative;
    span {
      display: inline-block;
      color: #00d1ff;
    }
    span:nth-child(1) {
      width: 6px;
      height: 6px;
      background: #00d1ff;
      border-radius: 50%;
    }
    span:nth-child(2) {
      margin-left: 15px;
    }
    span:nth-child(3) {
      position: absolute;
      right: 50px;
    }
  }
  .status-btn-8 {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-left: 1px solid rgba(241, 243, 249, 0.2);
    div:nth-child(1),
    div:nth-child(2) {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 80px;
      height: 32px;
      border-radius: 4px;
      background-color: #00384e;
    }
    div:nth-child(1) {
      border: 1px solid rgba(0, 209, 255, 0.7);
    }
    div:nth-child(2) {
      margin-top: 4px;
      border: 1px solid rgba(255, 85, 98, 0.7);
      background-color: rgba(255, 85, 98, 0.2);
    }
  }
  .square {
    display: flex;
    padding: 0 12px;
    .el-col {
      position: relative;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 100%;
      height: 100%;
      padding-top: 5px;
      padding-bottom: 5px;
      box-sizing: border-box;
      div:nth-child(1) {
        font-size: 18px;
        font-weight: bold;
        line-height: 27px;
      }
      div:nth-child(2) {
        font-size: 12px;
        line-height: 27px;
      }
      div:nth-child(3) {
        position: absolute;
        top: 0;
        left: 0;
        width: 0;
        height: 0;
        border-right: 10px solid transparent;
      }
    }
    .el-col:nth-child(1) {
      color: #cc77dc;
      background: rgba(204, 119, 220, 0.1);
      div:nth-child(3) {
        border-top: 10px solid #cc77dc;
      }
    }
    .el-col:nth-child(2) {
      position: relative;
      color: #00d1ff;
      margin: 0 16px;
      background: rgba(0, 209, 255, 0.1);
      div:nth-child(3) {
        border-top: 10px solid #00d1ff;
      }
    }
    .el-col:nth-child(3) {
      color: #73f6af;
      margin-right: 16px;
      background: rgba(115, 246, 175, 0.1);
      div:nth-child(3) {
        border-top: 10px solid #73f6af;
      }
    }
    .el-col:nth-child(4) {
      color: #ffad30;
      background: rgba(255, 173, 48, 0.1);
      div:nth-child(3) {
        border-top: 10px solid #ffad30;
      }
    }
  }
}
</style>
